﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace Cweek_8
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            /**
             * 
             */
            Label Label1 = new Label();//创建一个标签
            Label1.Parent = this;//指定父类
            Label1.Name = "Label1";//标签名
            Label1.Text = "Hello,World!";//文本内容
            Label1.Location = new Point(20, 30);//坐标
            Label1.AutoSize = true;

            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int ww = this.Width;//窗口的宽度
            int w1 = label1.Width;//标签Label1的宽度
            int x = (ww - w1) / 2;//计算Label1.x的值
            label1.Location = new Point(x, label1.Location.Y);
        }
    }
}
